package com.example.myapplication.screen

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.runtime.setValue
import androidx.compose.runtime.getValue
import androidx.compose.ui.graphics.Color


@Composable
fun CustomRangeProgressBar(innerPadding: PaddingValues) {
    var progressValue by remember { mutableStateOf(0) }  // 自定义进度范围为 0 到 100
    val maxProgress = 100

    Column(
        modifier = Modifier
            .fillMaxWidth()
            .padding(innerPadding),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Center
    ) {
        // 将进度值映射到 0f 到 1f 的范围
        LinearProgressIndicator(
            progress = { progressValue / maxProgress.toFloat() },
            color = Color.Yellow,       //前景色
            trackColor = Color.Gray    //轨道颜色
        )

        Spacer(modifier = Modifier.height(16.dp))

        // 按钮增加进度
        Button(
            onClick = {
                if (progressValue < maxProgress) {
                    progressValue += 10  // 增加进度
                }
            }
        ) {
            Text("更新进度")
        }

        Text(text = "Progress: $progressValue / $maxProgress")
    }
}